home *** CD-ROM | disk | FTP | other *** search
- Path: news.crystalball.com!news
- From: Larry Weiss <lfw@oc.com>
- Newsgroups: comp.lang.c
- Subject: named constants only?
- Date: Fri, 08 Mar 1996 10:11:26 -0600
- Organization: crystalball.com
- Message-ID: <31405C2E.6652@oc.com>
- References: <4g0elg$mdr@redstone.interpath.net> <4h0bbo$c0q@fohnix.metronet.com> <4h7ce0$ojd@news.interpath.net> <4h85sm$lm0@texas.nwlink.com> <danpop.825961872@rscernix> <313C5CD1.1209@oc.com> <4hmos4$ij2@news.interpath.net> <4hpd8a$d70@alterdial.UU.NET>
- NNTP-Posting-Host: external.oc.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (Win16; I)
-
- Tom Rogers wrote:
- >
- > ... Magic numbers are evil. Don't use them not even
- > once. Your code will be reused, by you or someone else. Even if
- > you just use a magic number in one place it doesn't mean that in
- > the future your routines won't get included in some other module
- > with other new routines that need to use the 'same' magic number.
- >
- > Furthermore, what does 5 or 7 or 10 mean? It is NOT self documenting.
- > Make it a well named constant and reduce the need for accompanying
- > comments describing what the value is.
-
-
- I challenge you to look at all your source and see if there are any
- "naked" constants in it. Most of the ones that you are likely to find
- will be easily justified as staying unobfuscated.
-
- The exercise will also most likely turn up some that are good candidates
- for the #define naming mechanism.
-